package com.atguigu.srb.sms.receiver;

import com.atguigu.srb.base.dto.SmsDTO;
import com.atguigu.srb.sms.service.SmsService;
import com.atguigu.srb.sms.util.SmsProperties;
import com.rabbitmq.client.Channel;
import lombok.SneakyThrows;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;


/**
 * 包名：com.atguigu.srb.sms.receiver
 *
 * @author Fun
 * 日期2021-11-14 19:36
 */
@Component
public class SmsReceiver {
    @Autowired
    SmsService smsService;

    @SneakyThrows
    @RabbitListener(bindings = @QueueBinding(
            exchange = @Exchange(value = "exchange.topic.sms"),
            key = {"routing.sms.item"},
            value = @Queue(value = "queue.sms.item")
    ))

    public void a(Channel channel, Message message, String jsonMap){
        System.out.println(jsonMap);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }
}
